import java.util.Arrays;

public class fev {
    import java.util.Arrays;

    public class SmallDui {
        int[] elem = new int[10];
        int usesize;

        public SmallDui() {
            elem = new int[10];
        }
        public void intimit(int[] arrray){
            for (int i = 0; i < arrray.length; i++) {
                elem[i] = arrray[i];
                usesize++;
            }
        }
        public void creatTree(){
            for (int parent = (usesize-1-1)/2; parent >=0; parent--) {
                sift(parent,usesize);
            }
        }

        private void sift(int parent, int usesize) {
            int child = parent*2+1;
            while(child<usesize){
                if(child<usesize-1 && elem[child]<elem[child+1]){
                    child=child+1;
                }
                if(elem[child]>elem[parent]){
                    swap(child,parent);
                    parent = child;
                    child = 2*parent + 1;
                }
                else {
                    break;
                }
            }
        }
        public void push(int val){
            if(isFull()){
                elem = Arrays.copyOf(elem,elem.length*2);
            }
            elem[usesize] = val;
            siftup(usesize);
            usesize++;
        }

        private void siftup(int child) {
            int parent = (child-1)/2;
            while(child>0){
                if(elem[child]>elem[parent])
                    swap(child,parent);
                child = parent;
                parent = (child-1)/2;
            }
        }

        private void swap(int i,int j) {
            int tem = elem[i];
            elem[i] = elem[j];
            elem[j] = tem;
        }

        public boolean isFull(){
            return usesize >= elem.length;
        }
        public int pop(){
            if(isEmpty()){
                return -1;
            }
            int old = elem[0];
            swap(0,usesize-1);
            usesize--;
            sift(0,usesize);
            return old;
        }

        private boolean isEmpty() {
            return usesize==0;
        }
        public int peek(){
            if (isEmpty()){
                return -1;
            }
            return elem[0];
        }
    }

}
